<template>
  <import src="../common/tpl/footer.tpl"/>
  <view class="index-page">
    <hello :from="from" @hello="handleHello"></hello>
    {{userInfo.name||'无名'}}
    <view class="click-tip" if="clicked">You click me~</view>
  </view>
  <tpl is="page-footer"/>
</template>
<script>
  import Util from '../common/js/util'
  import Hello from '../components/Hello';

  export default {
    config: {
      title: '小程序通用框架'
    },

    mixins: [Util],
    components: {
      Hello
    },

    data: {
      btnText: 'Hello',
      clicked: false,
      from: 'HomePage'
    },
    $store: {
      computed: {
        userInfo(state) {
          return state.common.userInfo
        }
      }
    },
    mounted() {
    },
    methods: {
      handleHello(e) {
        this.clicked = true;
        this.btnText = 'You clicked';
        let types = this.TYPES
        this.commit(types.UP_USERINFO, {
          userInfo: {
            name: '姓名'
          }
        })
        this.showMsg('OK')
      }
    }
  };
</script>
<style lang="less">
  .index-page {
    padding: 30px;
  }
</style>
